<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改城市</title>
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
<link rel="stylesheet" href="__PUBLIC__/admin/css/admin.css">
</head>
<body class="layui-bg-gray">
	<div class="layui-fluid">
		<div class="layui-row layui-col-space10">
			<div class="layui-col-md12 layui-col-xs12">
				<div class="layui-card">
					<div class="layui-card-body">
						<form class="layui-form" action="">
							<div class="layui-form-item">
								<label class="layui-form-label">上级城市</label>
								<div class="layui-input-block">
									<select name="pid" lay-verify="required"<notempty
											name="region">disabled = "disabled"</notempty>>
										<option value=""></option>
										<option value="0" {$region['pid']==0?'selected="selected"':''}>中国</option>
										<volist name="regions" id="value">
										<option value="{$value.id}" {$region['pid']==$value[
											'id']?'selected="selected"':''}>[{$value.code}]{$value.name}[省级]</option>
										<notempty name="value.children"> <volist
											name="value['children']" id="children">
										<option value="{$children.id}" {$region['pid']==$children[
											'id']?'selected="selected"':''}>&nbsp;&nbsp;&nbsp;&nbsp;[{$children.code}]{$children.name}[市县]</option>
										<notempty name="children.children"> <volist
											name="children['children']" id="child">
										<option value="{$child.id}" {$region['pid']==$child[
											'id']?'selected="selected"':''}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[{$child.code}]{$child.name}</option>
										</volist> </notempty> </volist> </notempty> </volist>
									</select>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">城市编码</label>
								<div class="layui-input-block">
									<input type="text" name="code" required lay-verify="required" value="{$region.code}"
										placeholder="请输入城市编码" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">城市名称</label>
								<div class="layui-input-block">
									<input type="text" name="name" required lay-verify="required" value="{$region.name}"
										placeholder="请输入城市名称" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">城市简称</label>
								<div class="layui-input-block">
									<input type="text" name="short_name" placeholder="请输入城市简称" value="{$region.short_name}"
										autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">排序</label>
								<div class="layui-input-block">
									<input type="text" name="sort_order" required value="{$region.sort_order}"
										lay-verify="required" value="0" autocomplete="off"
										class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-input-block">
									<button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script src="__PUBLIC__/layui/layui.js"></script>
	<script type="text/javascript"
		src="__PUBLIC__/common/js/jquery-2.0.3.min.js"></script>
	<script type="text/javascript">
		var nid = '{$region.id}';
		$(function() {
			layui.use('form', function() {
				var form = layui.form;
				form.on('submit(formDemo)', function(data) {
					var index = layer.load();
					$.ajax({
						type : "POST",
						url : "{:U('Settings/editRegion')}",
						data : {
							info : data.field,
							nid : nid
						},
						success : function(res) {
							layer.close(index);
							if (res.status == 1) {
								layer.msg(res.info);
								layui.data('cache', {
									key : 'status',
									value : true
								});
							} else {
								layer.msg(res.info);
							}
						}
					});
					return false;
				});
			});
		});
	</script>
</body>
</html>